#!/bin/sh
#
# Test main view display of index changes and interaction with the stage view.

. libtest.sh
. libgit.sh
. "$source_dir/util.sh"

export LINES=16

steps '
	:save-display main-with-unstaged.screen
	:enter
	:save-display main-with-unstaged-split.screen

	:/b.c CHANGED
	:status-update
	:status-update
	:0
	:save-display main-with-unstaged-and-staged-split.screen

	:status-update
	:save-display main-with-staged.screen

	:enter
	:save-display main-with-staged-split.screen

	:view-close
	:exec @git reset a b.c
	:refresh
	:save-display main-with-staged-and-unstaged.screen

	:exec @git reset --hard
	:exec @git mv b.c b1.c
	:refresh
	:save-display main-with-renamed.screen

	:exec @git mv b1.c b.c
	:exec @setup-conflict.sh
	:refresh
	:save-display main-with-conflict.screen

	:set line-graphics = ascii
	:view-refs
	:enter
	:maximize
	:save-display main-all-refs.screen
'

tigrc <<EOF
set vertical-split = no
EOF

in_work_dir create_dirty_workdir

test_tig

assert_equals 'main-with-unstaged.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Unknown    o Unstaged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit












[main] Unstaged changes                                                     100%
EOF

assert_equals 'main-with-unstaged-split.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Unknown    o Unstaged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit


[main] Unstaged changes                                                     100%
 .j  | 6 ++----
 a   | 6 ++----
 b.c | 6 ++----
 e/f | 6 ++----
 g h | 6 ++----
 5 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/.j b/.j
index e697dfd..9d8ef3d 100644
[stage] Press '<Enter>' to jump to file diff - line 1 of 107                  8%
EOF

assert_equals 'main-with-unstaged-and-staged-split.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Unknown    o Unstaged changes
$YYY_MM_DD_HH_MM +0000 Unknown    o Staged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit

[main] Unstaged changes                                                     100%
 .j  | 6 ++----
 a   | 6 ++----
 e/f | 6 ++----
 g h | 6 ++----
 4 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/.j b/.j
index e697dfd..9d8ef3d 100644
--- a/.j
[stage] Press '<Enter>' to jump to file diff - line 1 of 86                  10%
EOF

assert_equals 'main-with-staged.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Unknown    o Staged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit












[main] Staged changes                                                       100%
EOF

assert_equals 'main-with-staged-split.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Unknown    o Staged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit


[main] Staged changes                                                       100%
 .j  | 6 ++----
 a   | 6 ++----
 b.c | 6 ++----
 e/f | 6 ++----
 g h | 6 ++----
 5 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/.j b/.j
index e697dfd..9d8ef3d 100644
[stage] Press '<Enter>' to jump to file diff - line 1 of 107                  8%
EOF

assert_equals 'main-with-staged-and-unstaged.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Unknown    o Unstaged changes
$YYY_MM_DD_HH_MM +0000 Unknown    o Staged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit











[main] Unstaged changes                                                     100%
EOF

assert_equals 'main-with-renamed.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Unknown    o Staged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit












[main] Staged changes                                                       100%
EOF

assert_equals 'main-with-conflict.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Unknown    o Unstaged changes
2009-03-11 12:38 +0000 Committer  o [conflict-master] Change: c'
2009-03-03 00:15 +0000 Committer  o Change: c
2009-02-22 11:53 +0000 Committer  o [master] Change: b
2009-02-13 23:31 +0000 Committer  o Change: a
2009-02-13 23:31 +0000 A. U. Thor I Initial commit








[main] Unstaged changes                                                     100%
EOF

assert_equals 'main-all-refs.screen' <<EOF
2009-03-28 13:22 +0000 Committer  * [conflict-branch] Change: d'
2009-03-20 01:00 +0000 Committer  * Change: d
$YYY_MM_DD_HH_MM +0000 Unknown    | * Unstaged changes
2009-03-11 12:38 +0000 Committer  | * [conflict-master] Change: c'
2009-03-03 00:15 +0000 Committer  | * Change: c
2009-02-22 11:53 +0000 Committer  *-' [master] Change: b
2009-02-13 23:31 +0000 Committer  * Change: a
2009-02-13 23:31 +0000 A. U. Thor I Initial commit






[main] d62d8545d99da3de587bf2ef43703dde0ce68084 - commit 1 of 7             100%
EOF
